//
//  YXMachineMaterialCell.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/24.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXMachineMaterialCell.h"
#import "YXMachinesModel.h"
#import "YXWorkOrderModel.h"
@implementation YXMachineMaterialCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setModel:(YXMachinesModel *)model {
    _model = model;
    
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:_model.coverImgUrl] placeholderImage:[UIImage imageNamed:@""]];
    _titleLab.text = [NSString stringWithFormat:@"名称：%@",_model.name];
    _number.text = [NSString stringWithFormat:@"型号：%@",_model.model];
    
    self.typeLab.hidden = YES;
}

- (void)setDetailsModel:(YXMachinesModel *)detailsModel {
    _detailsModel = detailsModel;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:_detailsModel.coverImgUrl] placeholderImage:[UIImage imageNamed:@""]];
    _titleLab.text = [NSString stringWithFormat:@"名称：%@",_detailsModel.name];
    _typeLab.text = [NSString stringWithFormat:@"型号：%@",_detailsModel.model];
    _number.text = [NSString stringWithFormat:@"数量：%@台",_detailsModel.stock];
    _applyLab.text = [NSString stringWithFormat:@"单价：%@",_detailsModel.unitPrice];
}

- (void)setWorkModel:(YXWorkOrderModel *)workModel {
    _workModel = workModel;
    
    if ([_workModel.orderState isEqualToString:@"X"]) {
        _applyLab.text = @"处理中";
    }else if ([_workModel.orderState isEqualToString:@"Y"]) {
        _applyLab.text = @"已处理";
    }else if ([_workModel.orderState isEqualToString:@"Z"]) {
        _applyLab.text = @"已完成";
    }
    
    NSArray *goodsListArr = [YXWorkOrderModel mj_objectArrayWithKeyValuesArray:_workModel.ordersGoodsList];
    for (YXWorkOrderModel *model in goodsListArr) {
          [_picImageView sd_setImageWithURL:[NSURL URLWithString:model.coverImgUrl] placeholderImage:[UIImage imageNamed:@""]];
        _titleLab.text = [NSString stringWithFormat:@"名称：%@",model.goodsName];
        _typeLab.text = [NSString stringWithFormat:@"型号：%@",model.model];
        _number.text = [NSString stringWithFormat:@"数量：%@台",model.goodsNumber];

    }
}

@end
